package com.dhcc.sds.busi.controller;

import com.alibaba.fastjson.JSONArray;
import com.dhcc.cdc.busi.service.ICdcHospitalService;
import com.dhcc.cdc.busi.service.ICdcLocationService;
import com.dhcc.sds.base.service.ISdsCommonService;
import com.dhcc.sds.base.service.ISdsQcentityService;
import com.dhcc.sds.busi.service.IAnalysisSdsMstaService;
import com.dhcc.sds.busi.service.ISdsQcincaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 单病种质量绩效统计
 *
 * @ClassName: AnalysisSdsMstaController
 * @Description: TODO
 * @author zhangdc
 * @date 2021-06-27 10:09:15
 */
@Controller
@RequestMapping("${sys.backendPath}/analysis/sdsmsta")
public class AnalysisSdsMstaController {

    private String PREFIX = "/backend/sds/analysis/";

    @Autowired
    private IAnalysisSdsMstaService analysisSdsMstaService;

    @Autowired
    private ICdcHospitalService cdcHospitalService;

    @Autowired
    private ICdcLocationService cdcLocationService;

    @Autowired
    private ISdsQcentityService sdsQcentityService;

    @Autowired
    private ISdsQcincaseService sdsQcincaseService;

    @Autowired
    private ISdsCommonService sdsCommonService;


    /**
     * @Description: 首次进入单病种质量绩效统计
     * @Title: sdsMsta
     * @author: zhangdc
     * @date:2021-06-27 10:09:15
     */
    @RequestMapping("")
    public String index(Model model) {
        //获取部门信息
        JSONArray officMap = cdcHospitalService.getOfficeMap();
        //默认加载所有科室
        JSONArray departMap = sdsCommonService.getDepartMap(new HashMap<>());
        //获取病种
        JSONArray entityMap = sdsQcentityService.getUpEntityMap();
        //获取病种的年份
        JSONArray yearMap = sdsQcincaseService.getYearMap();
        //获取病种的月份
        JSONArray monthMap = sdsQcincaseService.getMonthMap();
        model.addAttribute("officeMap",officMap);
        model.addAttribute("departMap",departMap);
        model.addAttribute("entityMap",entityMap);
        model.addAttribute("yearMap",yearMap);
        model.addAttribute("monthMap",monthMap);
        model.addAttribute("hospitalId",sdsCommonService.getHospIdBySysUser());
        return PREFIX + "sdsmsta.html";
    }

    /**
     * @Description: 查询单病种质量绩效统计
     * @Title: selectSdsMsta
     * @return: Object
     * @author: zhangdc
     * @date:2021-06-27 10:09:15
     */
    @RequestMapping("selectSdsMsta")
    @ResponseBody
    public Object selectSdsMsta(@RequestParam Map<String, Object> params) {
        // 查询登录用户关联科室
        List<String> deptIds = sdsCommonService.getDeptIdsBySysUser();
        params.put("userLinkDepts", deptIds);
        return analysisSdsMstaService.selectSdsMsta(params);
    }

    /**
     * @Description: 查询单病种质量绩效统计表格
     * @Title: selectSdsMstaTable
     * @return: Object
     * @author: zhangdc
     * @date:2021-06-27 10:09:15
     */
    @RequestMapping("selectSdsMstaTable")
    @ResponseBody
    public Object selectSdsMstaTable(@RequestParam Map<String, Object> params) {
        // 查询登录用户关联科室
        List<String> deptIds = sdsCommonService.getDeptIdsBySysUser();
        params.put("userLinkDepts", deptIds);
        return analysisSdsMstaService.selectSdsMstaTable(params);
    }
}
